<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
use think\Request;


class Personal extends IndexController
{
    public function index()
    {
    	

        $pet = db('pet')->where('use_id',input('session.user.id'))->find();
        if($pet){
            $this->assign('mypet', $pet);    
        }

        //动态
        $dongtai = Db::field('u.icon,u.nickname,d.dtime,d.caozuo,d.use_id,d.id')
        ->table('bbs_user u, bbs_dongtai d')
        ->where('u.id = d.use_id')
        ->where('d.use_id',input('session.user.id'))
        ->order('dtime','desc')
        ->select();
        $this->assign('dongtai',$dongtai);

        $friends = Db::query('select u.icon,u.nickname,d.dtime,d.caozuo,d.use_id,d.id from bbs_user u,bbs_dongtai d where u.id=d.use_id and d.use_id  in (select t1.fid from (select * from bbs_friend where use_id = '.input('session.user.id').') as t1 inner join (select * from bbs_friend where fid = '.input('session.user.id').') as t2 on t1.fid = t2.use_id) order by d.dtime desc');
        $this->assign('friends',$friends);
        

    	
        return view('personal/index');
    }



    public function deldongtai()
    {
        $result = db('dongtai')->where('id',input('id'))->delete();
        return json(1);
    }


}
